
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using T2.WebSecurity.Business.Entities.Interfaces;
using T2.WebSecurity.Business.Entities.Search.Interfaces;
using T2.WebSecurity.Business.Entities;
using T2.WebSecurity.Business.Entities.Search;
using T2.WebSecurity.Business;
using T2.WebSecurity.Common;
using T2.WebSecurity.Common.Log;

//--Change Management Control - Workflow_OAuthMembership Code Behind  --**********************
//--Created By: trooks
//--Description:  Workflow_OAuthMembership Code Behind Class
//--Created Date: 03/07/2013 10:47:27
//--*************************************************************

namespace T2.WebSecurity.Business.Workflow
{
	public partial class  Workflow_OAuthMembership : SequentialWorkflowActivity
	{
        private T2.WebSecurity.Business.Commands.OAuthMembership_Command cmd = new T2.WebSecurity.Business.Commands.OAuthMembership_Command();
        public OAuthMembership_biz Parm { get; set; }
        public bool OAuthMembershipExists = false;
        public BusinessService bs = new BusinessService();
        public ApplicationException ex;
        public bool Valid = true;
        public Int32 RetVal { get; set; }
        public String ValidationErrors { get; set; }


        private void CallOAuthMembershipController_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                if (Valid)
                {
                    RetVal = Convert.ToInt32(cmd.Execute(Parm));
                }
                else
                {
                    RetVal = -1;
                
                }
            }
            catch (Exception ep)
            {
                ex = new ApplicationException(ep.Message, ep);
            }
        }

        protected void CheckAdd(object sender, ConditionalEventArgs e)
        {
            if (this.Parm == null || this.Parm.Action == MyEnum.Actions.Add.ToString())
            {
                e.Result = false;
            }
            else
            {
                e.Result = true;
            }
        }

        protected void CheckModify(object sender, ConditionalEventArgs e)
        {
            if (this.Parm == null || this.Parm.Action == MyEnum.Actions.Update.ToString())
            {
                e.Result = false;
            }
            else
            {
                e.Result = true;
            }
        }

        protected void CheckRemove(object sender, ConditionalEventArgs e)
        {
            if (this.Parm == null || this.Parm.Action == MyEnum.Actions.Remove.ToString())
            {
                e.Result = false;
            }
            else
            {
                e.Result = true;
            }
        }

        private void GetOAuthMembership_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                IOAuthMembership_biz myParm = new OAuthMembership_biz();
                myParm.Action = MyEnum.Actions.GetOne.ToString();
                myParm.OAuthMembershipID = Parm.OAuthMembershipID;
                
                List<IOAuthMembership_biz> ObjectList = bs.OAuthMembershipController_Get(myParm, false, false);
                if (ObjectList.Count > 0)
                {
                    OAuthMembershipExists = true;

                }
                else
                {
                   OAuthMembershipExists = false;
                }


            }
            catch (Exception ep)
            {
                ex = new ApplicationException(ep.Message, ep);
            }



        }

        private void SearchOAuthMembership_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                OAuthMembershipExists = false;
            }
            catch (Exception ep)
            {
                ex = new ApplicationException(ep.Message, ep);
            }

        }
		
        private void reportError_ExecuteCode(object sender, EventArgs e)
        {
			Common.Log.MyLogger.MyLog("T2.WebSecurity","Business","Error occured in OAuthMembership Workflow", MyEnum.LogCategories.Error, 10, 7010, System.Diagnostics.TraceEventType.Error, "Unknown Error Has Occured");
            
        }

        private void reportAddException_ExecuteCode(object sender, EventArgs e)
        {
            Common.Log.MyLogger.MyLog("T2.WebSecurity","Business","Error occured in OAuthMembership Workflow", MyEnum.LogCategories.Error, 10, 7010, System.Diagnostics.TraceEventType.Error, "Unknown Error Has Occured");
        }

        private void reportModifyException_ExecuteCode(object sender, EventArgs e)
        {
            Common.Log.MyLogger.MyLog("T2.WebSecurity","Business","Error occured in OAuthMembership Workflow", MyEnum.LogCategories.Error, 10, 7010, System.Diagnostics.TraceEventType.Error, "Unknown Error Has Occured");
        }

        private void reportDeleteException_ExecuteCode(object sender, EventArgs e)
        {
            Common.Log.MyLogger.MyLog("T2.WebSecurity","Business","Error occured in OAuthMembership Workflow", MyEnum.LogCategories.Error, 10, 7010, System.Diagnostics.TraceEventType.Error, "Unknown Error Has Occured");
        }

	}
}